package repositories;

import java.util.Collection;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import domain.Gallery;

@Repository
public interface GalleryRepository extends JpaRepository<Gallery, Integer> {

	@Query("select g from Gallery g where g.customer.id = ?1")
	Collection<Gallery> findByCustomer(int customerId);

	@Query("select p.gallery.id, sum(p.appraisal.amount) from Painting p group by p.gallery.id")
	Collection<Object[]> findByTotalAppraisal();
}
